package com.udi.project.business.local.di.thread;

import com.udi.common.utils.spring.SpringUtils;
import com.udi.project.business.utils.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author Admin
 * 回收项目代码
 */
public class Recycle extends Thread{

    @Autowired
    private RedisUtils redisUtils;

    public Recycle(){
        this.redisUtils = SpringUtils.getBean(RedisUtils.class);
    }

   @Override
   public void run(){
       List<Object> data = redisUtils.lGet("model",0,-1);
       String project = "";
       for (Object di:data){
           project = (String) di;
           if(project.length() == 13 || project.length() == 14){
             Object code = project.substring(8,12);
               redisUtils.lSet("recycle",code);
           }else if(project.length() == 8){
               Object code = project.substring(1,3);
               redisUtils.lSet("recycle",code);
           }

       }
       redisUtils.del("model");
   }
}
